import Cookies from 'js-cookie'

const TokenKey = 'Admin-Token'

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  return Cookies.set(TokenKey, token)
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}

export function setUserInfo(userInfo) {
  Cookies.set('userinfo', JSON.stringify(userInfo))
}

export function getUserInfo() {
  const rt = Cookies.get('userinfo')
  if (rt) {
    return JSON.parse(rt)
  }
  return rt || {}
}
